<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="assets/css/bootstrap.min.css" rel="stylesheet" />
        <link rel="stylesheet" href="css/style.css"/>
        <link href="assets/css/codemirror.css" rel="stylesheet">
        <link rel="stylesheet" href="assets/css/ace.min.css" />
        <link rel="stylesheet" href="assets/css/font-awesome.min.css" />
        <style>
            #search{
                width:200px;
                display:inline;
                margin-top:15px;
                margin-bottom:15px;
                margin-right:15px;
            }
        </style>
		<!--[if IE 7]>
		  <link rel="stylesheet" href="assets/css/font-awesome-ie7.min.css" />
		<![endif]-->
        <!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->
			<script src="assets/js/jquery.min.js"></script>

		<!-- <![endif]-->

		<!--[if IE]>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<![endif]-->

		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
		<script src="assets/js/bootstrap.min.js"></script>
		<script src="assets/js/typeahead-bs2.min.js"></script>
		<!-- page specific plugin scripts -->
		<script src="assets/js/jquery.dataTables.min.js"></script>
		<script src="assets/js/jquery.dataTables.bootstrap.js"></script>
        <script type="text/javascript" src="js/H-ui.js"></script>
        <script type="text/javascript" src="js/H-ui.admin.js"></script>
        <script src="assets/layer/layer.js" type="text/javascript" ></script>
        <script src="assets/laydate/laydate.js" type="text/javascript"></script>
<title>用户列表</title>
</head>

<body>
<div class="page-content clearfix">
    <div id="Member_Ratings">
      <div class="d_Confirm_Order_style">
      <input id="search" class="form-control"  type="text" placeholder="查询请输入用户名字"/><button type="button" class="btn btn-info">查询</button>
     <div class="table_menu_list">
       <table class="table table-striped table-bordered table-hover" id="sample-table">
		<thead>
		 <tr>
				<th width="25"><label><input type="checkbox" class="ace"><span class="lbl"></span></label></th>
				<th width="80">ID</th>
				<th width="100">用户名</th>
				<th width="100">头像</th>
				<th width="80">性别</th>
				<th width="120">openid</th>
				<th width="150">session_key</th>
				<th width="150">地址</th>
				<th width="100">状态</th>
				<th width="160">操作</th>
			</tr>
		</thead>
	<tbody>

      </tbody>
	</table>
   </div>
  </div>
 </div>
</div>
</body>
</html>
<script>
jQuery(function($) {
        $('table th input:checkbox').on('click' , function(){
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
            .each(function(){
                this.checked = that.checked;
                $(this).closest('tr').toggleClass('selected');
            });

        });

    })

 /** 用户查询*/
 $('.d_Confirm_Order_style').find("button").on('click',function(){
    var search_txt = $('.d_Confirm_Order_style').find("input[type='text']").val();
    $.ajax({
        url:"user/userDimQuery.php",
        type:"post",
        data:{
            content:search_txt
        },
        datatype:"json",
        success:function(data){
            layer.open({
                title:"提示",
                content:data.msg
            });
            paintDOM(data.data);

        }
    });
 });
/*用户-删除*/
function member_del(obj,id){
	layer.open({
	    title:"警告",
	    content:"确定要删除吗?",
	    btn:['确定','取消'],
	    yes:function(index,layero){
	         $.ajax({
                url:"user/userDel.php",
                type:"post",
                datatype:"json",
                data:{
                    id:id
                },
                success:function(data){
                    console.log(data);
                    layer.msg('已删除!',{icon:1,time:1000});
                    $(obj).parents("tr").remove();
                },
                error:function(e){
                    console.log(e);
                }
            });
            layer.close(index);
	    }
	});
}

function queryAll(){
    $.ajax({
        type:"post",
        url:"user/userQueryAll.php",
        datatype:"json",
        data:"",
        success:function(data){
           console.log(data);
           paintDOM(data);
        }
    });
}

function paintDOM(data){
            var tbody = $("tbody")[0];
            var domlist = "";
            for(let i=0,len=data.length;i<len;i++){
                var value=data[i];
                domlist+="<tr>";
                domlist+=' <td><label><input type="checkbox" class="ace" data-index="'+value['id']+'"><span class="lbl"></span></label></td>';
                domlist+='<td>'+value['id']+'</td>';
                domlist+=' <td><u style="cursor:pointer" class="text-primary" >'+value['user_nick']+'</u></td>';
                domlist+='<td><img width="50" height="50" src="'+value['user_imgUrl']+'"/></td>';
                domlist+='<td>'+value['user_sex']+'</td>';
                domlist+='<td>'+value['user_openid']+'</td>';
                domlist+='<td class="text-l">'+value['user_session_key']+'</td>';
                domlist+='<td>'+value['addr_dtl']+'</td>';
                if(value['user_status']=="1"){
                   domlist+='<td class="td-status"><span class="label label-success radius">显示</span></td>';
                }else if(value['user_status']=="-1"){
                    domlist+='<td class="td-status"><span class="label label-danger radius">隐藏</span></td>';
                }

                domlist+=' <td class="td-manage">';
                domlist+='<a title="删除" href="javascript:;" data-index="'+value['id']+'"  onclick="member_del(this,'+value['id']+')" class="btn btn-xs btn-warning" ><i class="icon-trash  bigger-120"></i></a>';
                domlist+='</td>';
                domlist+='</tr>';

            }
            tbody.innerHTML=domlist;
}
queryAll();
</script>